package ${packageName}.model.entity.${moduleName};

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

import java.io.Serializable;
import java.time.Instant;
import java.math.BigDecimal;
import lombok.Data;
<#if useLombok>
import lombok.Data;
</#if>
/**
 * ${classInfo.classComment}
 *
 * @author ${authorName} ${.now?string('yyyy-MM-dd')}
 */
<#if useLombok>
@Data
@NoArgsConstructor
@AllArgsConstructor
</#if>
@TableName(value = "${classInfo.tableName}",autoResultMap = true)
public class ${classInfo.className} implements Serializable {
    private static final long serialVersionUID = 1L;

    <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
    <#list classInfo.fieldList as fieldItem >
    /**
     * ${fieldItem.fieldComment}
     */
    <#if fieldItem.fieldName == "id" || fieldItem.fieldName == "${classInfo.className}Id">
    @TableId(value="${fieldItem.columnName}",type= IdType.ASSIGN_ID)
    @JsonSerialize(using= ToStringSerializer.class)
    </#if>
    <#if fieldItem.fieldName == "createdDate" || fieldItem.fieldName == "createdBy" || fieldItem.fieldName == "lastModifiedDate"
        || fieldItem.fieldName == "lastModifiedBy" || fieldItem.fieldName == "updated_time">
    @TableField(value = "${fieldItem.columnName}", fill = FieldFill.INSERT_UPDATE)
    </#if>
    <#if fieldItem.fieldClass == "Date" || fieldItem.fieldClass == "Instant" || fieldItem.fieldClass == "LocalDateTime">
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
    </#if>
    <#if fieldItem.fieldClass == "List<String>" >
    @TableField(typeHandler = com.dbapp.dsc.config.ArrayTypeHandler.class, jdbcType = JdbcType.VARCHAR)
    @JsonSerialize(using = ToStringSerializer.class)
    </#if>
    <#if fieldItem.fieldClass == "List<Long>" >
    @TableField(typeHandler = com.dbapp.dsc.config.ArrayTypeHandler.class, jdbcType = JdbcType.BIGINT)
    @JsonSerialize(using = ToStringSerializer.class)
    </#if>
    <#if fieldItem.required && fieldItem.fieldName != "id">
    @NotNull
    </#if>
    <#if fieldItem.size gt 0>
    @Size(max = ${fieldItem.size?c})
    </#if>
    private ${fieldItem.fieldClass} ${fieldItem.fieldName};


    </#list>
<#if !useLombok>
    <#list classInfo.fieldList as fieldItem >
    <#if fieldItem.fieldName != "createdDate" && fieldItem.fieldName != "createdBy" && fieldItem.fieldName != "lastModifiedDate"  && fieldItem.fieldName != "lastModifiedBy">
    public ${fieldItem.fieldClass} get${fieldItem.fieldName?cap_first}() {
        return ${fieldItem.fieldName};
    }
    public void set${fieldItem.fieldName?cap_first}(${fieldItem.fieldClass} ${fieldItem.fieldName}) {
        this.${fieldItem.fieldName} = ${fieldItem.fieldName};
    }

    </#if>
    </#list>
</#if>
</#if>

}
